﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace msBsc.WebUi.mMall.Buyer
{
    public partial class mfUserInfo : msBsc.Cls.mbPCustom
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        private void getUserInfo()
        {
            using (msBsc.AppLogic.DataAlc.CBizCustomerBaseInfo objCBizCustomerBaseInfo = new AppLogic.DataAlc.CBizCustomerBaseInfo())
            {
                System.Data.DataSet ds = objCBizCustomerBaseInfo.SelectById(msBsc.SvRef.UserInfo.Operator);

                if (ds.Tables[0].Rows[0]["CUSTOMER_ALIPAY_ACCOUNT"] == System.DBNull.Value
                    || string.IsNullOrEmpty(ds.Tables[0].Rows[0]["CUSTOMER_ALIPAY_ACCOUNT"].ToString()))
                {
                    this.ExecJScript(@"SetUserAliAccount(""/mb_BindBalanceInfo.htm"",""支付宝绑定"")");
                    //usrAccountStr = @"<li ><a class="""" href=""/ws_BindBalanceInfo.htm"">账户绑定</a></li>";
                }
                //else if (ds.Tables[0].Rows[0]["CUSTOMER_IS_CREFY"] == System.DBNull.Value
                //    || ds.Tables[0].Rows[0]["CUSTOMER_CREFY_STATUS"] == System.DBNull.Value
                //    || System.Convert.ToInt32(ds.Tables[0].Rows[0]["CUSTOMER_CREFY_STATUS"]) != (int)msBsc.AppLogic.DataAlc.CrefEnum.PassCref)
                //{
                //    this.ExecJScript(@"SetUserAliAccount(""/mb_CrecityfyAlipayAccount.htm"",""支付宝认证"")");
                //    //usrAccountStr = @"<li ><a class="""" href=""/ws_CrecityfyAlipayAccount.htm"">账户认证</a></li>";
                //}
                //else if (System.Convert.ToInt32(ds.Tables[0].Rows[0]["CUSTOMER_CREFY_STATUS"]) == (int)msBsc.AppLogic.DataAlc.CrefEnum.PassCref)
                else
                {
                    //this.ExecJScript(@"SetUserAliAccount(""/mb_ClearBalanceInfo.htm"",""支付宝解绑"")");
                    //usrAccountStr = @"<li ><a class="""" href=""#"">账户解绑</a></li>";

                }
            }


            string userId = msBsc.SvRef.UserInfo.Operator;
            if (string.IsNullOrEmpty(userId))
            {
                return;
            }
            using (msBsc.AppLogic.DataAlc.CBizCustomerBaseInfo userInfo = new AppLogic.DataAlc.CBizCustomerBaseInfo())
            {
                DataSet ds = userInfo.GetVisitorByIds(userId);
                if (ds != null)
                {
                    string ret = msBsc.AppLogic.Cfg.HttpTools.GetJsonByTable(ds.Tables[0], "", "", 1, 50, "");
                    this.ExecJScript(@"showUserInfo(" + ret + ")");
                }
            }
        }

        public override void DoAction()
        {
            if (this.strAction == "init")
            {
                getUserInfo();
            }
        }
    }
}